%ifndef _MEMCPY_ASM_
%define _MEMCPY_ASM_

; void __cdecl memcpy(void* destination, void* source, size_t length)

%define destination dword [ebp + 8]
%define source dword [ebp + 12]
%define length dword [ebp + 16]
global memcpy
memcpy:
    push ebp
    mov ebp, esp
    push edi
    push esi
    mov edi, destination
    mov esi, source
    mov ecx, length
memcpy.copy_dword:
    mov dl, byte [esi + ecx - 1]
    mov byte [edi + ecx - 1], dl
    loop memcpy.copy_dword
    mov eax, edi
    pop esi
    pop edi
    mov esp, ebp
    pop ebp
    ret
%undef destination
%undef source
%undef length
%endif